package com.ruibang.glass.produce.controller.system;

import com.ruibang.glass.produce.domain.req.CombinationTrendChartReq;
import com.ruibang.glass.produce.domain.req.ExportMonitorDataReq;
import com.ruibang.glass.produce.domain.req.HistMonitorDataReq;
import com.ruibang.glass.produce.service.MonitorDataService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Map;

/**
 * @Author: songJinKang
 * @CreateTime: 2023-11-20  14:45
 * @Description: TODO
 * @Version: 1.0
 */

@Api(tags = "监测数据控制器(设备、生产模块实时数据)")
@RestController
@RequestMapping("/api/glass/data/monitor")
public class MonitorDataController {

    @Autowired
    private MonitorDataService monitorDataService;

    @PostMapping("/queryHistMonitorDataCurve")
    @ApiOperation(value = "获取监测点曲线图", response = ResultBody.class)
    public ResultBody queryHistMonitorDataCurve(@RequestBody HistMonitorDataReq histMonitorData) {
        return ResultBody.success(monitorDataService.queryHistMonitorDataCurve(histMonitorData));
    }

    @PostMapping("/queryHistMonitorData")
    @ApiOperation(value = "获取监测点历史数据", response = ResultBody.class)
    public ResultBody queryHistMonitorData(@RequestBody @Valid HistMonitorDataReq histMonitorData) {
        return ResultBody.success(monitorDataService.queryHistMonitorData(histMonitorData));
    }

    @PostMapping("/exportMonitorData")
    @ApiOperation(value = "导出监测点历史数据", response = ResultBody.class)
    public void exportMonitorData(@RequestBody @Valid ExportMonitorDataReq exportMonitorDataReq, HttpServletResponse response) {
        monitorDataService.exportMonitorData(exportMonitorDataReq, response);
    }

    @PostMapping("/combinationTrendChart")
    @ApiOperation(value = "组合趋势图", response = ResultBody.class)
    public ResultBody combinationTrendChart(@RequestBody CombinationTrendChartReq combinationTrendChartReq) {
        return ResultBody.success(monitorDataService.combinationTrendChart(combinationTrendChartReq));
    }
}
